package com.xiaodai.miaosha.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaodai.miaosha.entity.Msuser;
import com.xiaodai.miaosha.entity.Screening;
import com.xiaodai.miaosha.service.IMsuserService;
import com.xiaodai.miaosha.service.IScreeningService;
import com.xiaodai.miaosha.vo.RespBean;
import com.xiaodai.miaosha.vo.RespBeanEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaodai
 * @since 2022-04-12
 */
@Controller
@RequestMapping("/screening")
public class ScreeningController {
    @Autowired
    private IMsuserService userService;
    @Autowired
    private IScreeningService screeningService;


    public void doScreening(Msuser msuser){

        Screening screening = new Screening();
        Screening msuser_id = screeningService.getOne(new QueryWrapper<Screening>().eq("msuser_id", msuser.getId()));
        screening.setPassed(check(msuser)?1:0);
        if (msuser_id==null){

            screening.setMsuserId(String.valueOf(msuser.getId()));
            screeningService.save(screening);
        }
        screeningService.updateById(screening);

    }

    public Boolean check(Msuser msuser){
//        if (msuser.getOverdueRecords()>2||msuser.getInDefaultList()==1||msuser.getWorkStatus()==1|msuser.getWorkStatus()==2){
//            return false;
//        }
        return true;
    }



}
